package com.xunyin.modules.maincoupon.rest;

import com.alibaba.fastjson.JSONObject;
import com.xunyin.api.ApiResult;
import com.xunyin.modules.log.AppLog;
import com.xunyin.modules.maincouponsend.domain.TMainCouponUser;
import com.xunyin.modules.maincouponsend.param.TMainCouponParam;
import com.xunyin.modules.maincouponsend.service.TMainCouponUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 优惠券控制器
 * </p>
 *
 * @author admin
 * @since 2022-10-24
 */
@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(value = "优惠券模块", tags = "共享空间:优惠券模块")
public class MainCouponController {

    private final TMainCouponUserService tMainCouponUserService;

    /**
     * 查询不可使用优惠券列表
     *
     * @param jsonObject
     * @return
     */
    @RequestMapping(value = "/getNoUseCouponInfo", method = RequestMethod.POST)
    public JSONObject getNoUseCouponInfo(@RequestBody JSONObject jsonObject) {
        return tMainCouponUserService.getNoUseCouponInfo(jsonObject);
    }


    /**
     * 查询优惠券列表
     */
    @AppLog(value = "查询优惠券列表", type = 1)
    //@AuthCheck
    @PostMapping("/getUserCouponInfo")
    @ApiOperation(value = "查询优惠券列表", notes = "查询优惠券列表")
    public ApiResult<List<TMainCouponUser>> getUserCouponList(@Validated @RequestBody TMainCouponParam tMainCouponParam) {
        List<TMainCouponUser> list = tMainCouponUserService.getUserCouponList(tMainCouponParam);
        return ApiResult.ok(list);
    }

}
